Sort (Language Theory)

Sorts divide Abstract Syntax Trees into syntactic categories. For example, programming languages typically have a syntactic distinction between expressions and commands, these are two examples of sorts. This allows an operator in an AST to accept only specific sorts, since for example an operator that wants to accept an expression probably doesn’t want to accept a command.